package com.easygoods.request;

import com.bestvike.stone.spring.exception.AssertUtils;
import com.bestvike.stone.spring.rest.IRequest;
import com.easygoods.service.ConfigService;
import lombok.Data;

import java.math.BigDecimal;

/**
 * Created by 许崇雷 on 2019-02-20.
 */
@Data
public class DrawCashRequest implements IRequest {
    private String payPwd;//支付密码
    private BigDecimal amount;

    @Override
    public void assertValid() {
        AssertUtils.hasText(this.payPwd, "payPwd");
        AssertUtils.isTrue(this.payPwd.length() == ConfigService.getPayPwdLength(), "支付密码长度必须为 " + ConfigService.getPayPwdLength());
        AssertUtils.notNull(this.amount, "amount");
        AssertUtils.isTrue(this.amount.compareTo(BigDecimal.ZERO) > 0, "提现金额必须大于 0");
    }
}
